package com.example.login_demo.slice;

import com.example.login_demo.ResourceTable;
import com.example.login_demo.UserAbility;
import com.example.login_demo.base.BaseAbilitySlice;
import com.example.login_demo.common.Constant;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.window.dialog.ToastDialog;

import java.util.logging.Logger;


public class MainAbilitySlice extends BaseAbilitySlice implements Component.ClickedListener {


    private Button mBtLogin;
    private Button mBtRegister;

    @Override
    public int getLayout() {
        return ResourceTable.Layout_main_layout;
    }

    @Override
    public void initView() {
        mBtLogin = (Button) findComponentById(ResourceTable.Id_login);// 登录
        mBtRegister = (Button) findComponentById(ResourceTable.Id_register);// 注册
    }

    @Override
    public void initListener() {
        mBtLogin.setClickedListener(this);
        mBtRegister.setClickedListener(this);
    }


    @Override
    public void onClick(Component component) {
        switch (component.getId()) {
            case ResourceTable.Id_login:
                openAbility(null, UserAbility.class,null);
                break;
            case ResourceTable.Id_register:
                openAbility(null, UserAbility.class, Constant.UserLogin_SliceActionName);

                break;
        }
    }
}
